package com.cskaoyan.service;

import com.cskaoyan.dao.OrderDao;
import com.cskaoyan.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author stone
 * @date 2022/11/11 14:28
 */
//@Component //orderServiceImpl
@Component("orderService") //orderService
public class OrderServiceImpl implements OrderService{

    OrderDao orderDao;

    // @Autowired增加在方法上，该方法会自动执行
    //形参：默认按照类型从容器中取出组件，给到这个形参
    //如果在形参写的这个类型的组件在容器中不止一个，额外指定组件id → @Qualifier
    @Autowired
    public void setOrderDao(@Qualifier("orderDaoImpl") OrderDao orderDao) {
        this.orderDao = orderDao;
    }

    //默认按照类型从容器中取出组件
    //这个类型的组件在容器中不止一个，额外指定组件id → @Qualifier
    @Autowired
    @Qualifier("orderDaoImpl2")
    OrderDao orderDao2;

    @Autowired
    UserDao userDao;
    @Resource
    UserDao userDao2;
}
